<template>
  <div class="container">
    <ChatBox :userList="userList"></ChatBox>
  </div>
</template>

<script>
import ChatBox from "../../components/chat/ChatBox.vue";
export default {
  components: {
    ChatBox
  },
  data() {
    return {
      userList: ""
    };
  },
  mounted() {
    this.getChatList();
  },
  methods: {
    getChatList() {
      var _this = this;
      this.$axios
        .get("teacher/chatlist")
        .then(response => {
          let stateCode = response.headers["state"];
          if (stateCode == "200") {
            this.userList = response.data;
          } else if (stateCode == null) {
            this.$message.success("请求数据异常！");
          } else {
            this.$message.error(this.$enum.getDescByValue("STATE", stateCode));
          }
        })
        .catch(function(error) {
          let stateCode = error.response.headers["state"];
          if (stateCode != "") {
            _this.$message.error(
              _this.$enum.getDescByValue("STATE", stateCode)
            );
          } else {
            _this.$message.error("后端异常");
          }
        })
        .then(function() {
          console.log("测试成功");
        });
    }
  }
};
</script>

<style lang="less" scoped>

.container {
    height: 100%;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}
</style>
